/* Copyright 2008 Bas van den Berg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MUDEXIT_H
#define MUDEXIT_H

#include <memory>

#include "MudObject.h"

namespace Chronos {

class CmdVisitor;
class MudPlayer;
class Area;


class Portal {
public:
	virtual ~Portal() {}
	virtual void pass(MudPlayer& player) = 0;
};


class RoomPortal : public Portal {
public:
    RoomPortal(Area& area_
			, int destRoomID_
			, const std::string& arriveMsg_
			, const std::string& leaveMsg_
			, const std::string& enterMsg_);

	virtual void pass(MudPlayer& player);
private:
    Area& area;
    int destRoomID;
    const std::string arriveMsg;
    const std::string leaveMsg;
	const std::string enterMsg;

    RoomPortal(const RoomPortal& rhs);
    RoomPortal& operator=(const RoomPortal&);
};


class AreaPortal : public Portal {
public:
    AreaPortal(int destAreaID_
			, int destRoomID_
			, const std::string& arriveMsg_
			, const std::string& leaveMsg_
			, const std::string& enterMsg_);

    virtual void pass(MudPlayer& player);
private:
	int destAreaID;
    int destRoomID;
    const std::string arriveMsg;
    const std::string leaveMsg;
	const std::string enterMsg;

    AreaPortal(const AreaPortal& rhs);
    AreaPortal& operator=(const AreaPortal&);
};


class MudExit : public MudObject {
public:
    MudExit(const std::string& name_
			, const std::string& descr_
			, Portal* portal_);
    virtual ~MudExit();
    virtual void accept(CmdVisitor& v);

    virtual void pass(MudPlayer& player);
private:
    bool canPass(MudPlayer& player);
	std::auto_ptr<Portal> portal;

	MudExit(const MudExit& rhs);
    MudExit& operator=(const MudExit&);
};


class MudRoomExit : public MudExit {
public:
	MudRoomExit(const std::string& name_
			, const std::string& descr_
			, const std::string& arriveMsg_
			, const std::string& leaveMsg_
			, const std::string& enterMsg_
			, Area& area_
			, unsigned int destRoomID_);
};


class MudNorthExit : public MudExit {
public:
	MudNorthExit(Area& area_, int destRoomID_);
};


class MudEastExit : public MudExit {
public:
	MudEastExit(Area& area_, int destRoomID_);
};


class MudSouthExit : public MudExit {
public:
	MudSouthExit(Area& area_, int destRoomID_);
};


class MudWestExit : public MudExit {
public:
	MudWestExit(Area& area_, int destRoomID_);
};


class MudUpExit : public MudExit {
public:
	MudUpExit(Area& area_, int destRoomID_);
};


class MudDownExit : public MudExit {
public:
	MudDownExit(Area& area_, int destRoomID_);
};

}

#endif

